/*
 * @lc app=leetcode.cn id=225 lang=cpp
 *
 * [225] 用队列实现栈
 */

#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

// @lc code=start
class MyStack {

    queue<int> queue1;
    queue<int> queue2;

public:
    MyStack() {
        
    }
    
    void push(int x) {
        int length = queue1.size();
        queue1.push(x);
        while (length--) {
            int tmp = queue1.front();
            queue1.pop();
            queue1.push(tmp);
        }
    }
    
    int pop() {
        int result = queue1.front();
        queue1.pop();
        return result;
    }
    
    int top() {
        return queue1.front();
    }
    
    bool empty() {
        return queue1.empty();
    }
};

/**
 * Your MyStack object will be instantiated and called as such:
 * MyStack* obj = new MyStack();
 * obj->push(x);
 * int param_2 = obj->pop();
 * int param_3 = obj->top();
 * bool param_4 = obj->empty();
 */
// @lc code=end

